package com.yanlin.internalcommon.util;

import java.util.StringJoiner;

/**
 * <p>标题：RedisPrefixUtil</p>
 * <p>功能：</p>
 * <p>
 * 其他说明：
 * </p>
 * <p>审核：</p>
 * <p>重构：</p>
 * <p>创建日期：2025-06-07 12:49</p>
 *
 * @author yanlin
 */
public class RedisPrefixUtil {
    public static String VERIFICATION_CODE_PREFIX = "verification-code-";
    public static String TOKEN_PREFIX = "token";
    public static int VERIFICATION_CODE_EXPIRATION = 2;
    public static int ACCESS_TOKEN_EXPIRATINO = 30;
    public static int REFRESH_TOKEN_EXPIRATINO = ACCESS_TOKEN_EXPIRATINO + 1;

    /**
     * 生成验证码redis's key
     * @param phone
     * @return
     */
    public static String getVerificationCodeKey(String phone, String identity) {
        return VERIFICATION_CODE_PREFIX + identity + "-" + phone;
    }

    /**
     * 生成令牌redis's key
     * @param phone
     * @param identity
     * @param tokenType
     * @return
     */
    public static String getTokenKey(String phone, String identity, String tokenType) {
        StringJoiner joiner = new StringJoiner("-");
        return joiner.add(TOKEN_PREFIX).add(phone).add(identity).add(tokenType).toString();
    }
}